package com.hkts.management.unattended.pomain.service.serviceimpl;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hkts.management.unattended.pomain.entity.HktsPoPomain;
import com.hkts.management.unattended.pomain.mapper.HktsPoPomainMapper;
import com.hkts.management.unattended.pomain.service.IHktsPoPomainService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.apache.commons.lang.StringUtils;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;

import java.util.List;
/**
 * <p>
 * 采购订单 服务实现类
 * </p>
 *
 * @author yck
 * @since 2021-09-16
 */
@Service
@Transactional
public class HktsPoPomainServiceImpl extends ServiceImpl<HktsPoPomainMapper, HktsPoPomain> implements IHktsPoPomainService {


@Autowired
private HktsPoPomainMapper hktsPoPomainMapper;

@Override
public IPage<HktsPoPomain> selectPage(Page<HktsPoPomain> page, HktsPoPomain hktsPoPomain){
        QueryWrapper<HktsPoPomain> query = Wrappers.query();
        QueryWrapper<HktsPoPomain> entityWrapper = getEntityWrapper(query, hktsPoPomain);
        return hktsPoPomainMapper.selectPage(page, entityWrapper);
        }




@Override
public List<HktsPoPomain> selectList(HktsPoPomain hktsPoPomain){
        QueryWrapper<HktsPoPomain> query = Wrappers.query();
        QueryWrapper<HktsPoPomain> entityWrapper = getEntityWrapper(query, hktsPoPomain);
        return hktsPoPomainMapper.selectList(entityWrapper);
        }

/**
 *  公共查询条件
 * @param entityWrapper
 * @return
 */
public QueryWrapper<HktsPoPomain> getEntityWrapper(QueryWrapper<HktsPoPomain> entityWrapper,HktsPoPomain hktsPoPomain){
        //条件拼接
                if(StringUtils.isNotBlank(hktsPoPomain.getcPoid())){
                entityWrapper.like(HktsPoPomain.C_POID,hktsPoPomain.getcPoid());
                }
/*                if(StringUtils.isNotBlank(hktsPoPomain.getdPoDate())){
                entityWrapper.like(HktsPoPomain.D_PO_DATE,hktsPoPomain.getdPoDate());
                }*/
                if(StringUtils.isNotBlank(hktsPoPomain.getcPTCode())){
                entityWrapper.like(HktsPoPomain.C_P_T_CODE,hktsPoPomain.getcPTCode());
                }
                if(StringUtils.isNotBlank(hktsPoPomain.getcDepCode())){
                entityWrapper.like(HktsPoPomain.C_DEP_CODE,hktsPoPomain.getcDepCode());
                }
                if(StringUtils.isNotBlank(hktsPoPomain.getcPersonCode())){
                entityWrapper.like(HktsPoPomain.C_PERSON_CODE,hktsPoPomain.getcPersonCode());
                }
                if(StringUtils.isNotBlank(hktsPoPomain.getcVenCode())){
                entityWrapper.like(HktsPoPomain.C_VEN_CODE,hktsPoPomain.getcVenCode());
                }
                if(StringUtils.isNotBlank(hktsPoPomain.getcInvCode())){
                entityWrapper.like(HktsPoPomain.C_INV_CODE,hktsPoPomain.getcInvCode());
                }
                if(StringUtils.isNotBlank(hktsPoPomain.getcUnitLd())){
                entityWrapper.like(HktsPoPomain.C_UNIT_LD,hktsPoPomain.getcUnitLd());
                }
              /*  if(StringUtils.isNotBlank(hktsPoPomain.getiQuantity())){
                entityWrapper.like(HktsPoPomain.I_QUANTITY,hktsPoPomain.getiQuantity());
                }*/
        return entityWrapper;
        }
        }
